<?php
header("Content-Type:text/html;charset=utf-8");
/**抽象原型类
 * Class Prototype
 */
abstract class Prototype
{
    abstract function cloned();
}

/**具体原型类
 * Class Plane
 */
class Plane extends Prototype
{

    public $color;

    function Fly()
    {
        echo "飞机飞啊飞!<br/>";
    }

    function cloned()
    {
        return clone $this;
    }
}


//------------------------原型模式测试代码------------------
$plane1=new Plane();
$plane1->color="Blue";

$plane2=$plane1->cloned();

$plane1->Fly();
$plane2->Fly();

echo "plane1的颜色为：{$plane1->color}<br/>";
echo "plane2的颜色为：{$plane2->color}<br/>";
